import { defineStore } from 'pinia'
import { getItem, setItem } from '@/utils/localStorage'
const key = '_user'

// 定义 Store
export const useUserStore = defineStore('_user', {
  state: () => {
    return {
      user: getItem(key) || {}
    }
  },
  actions: {
    setUser(val: object) {
      this.user = val
      setItem(key, val)
    }
  }
})
